<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
    <title>系统登录</title>
    <link href="/public/plugins/bootstrap/css/bootstrap.min.css" rel="stylesheet">
    <link href="/public/plugins/fontawesome/css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <link href="/public/plugins/animate/animate.css" rel="stylesheet">
    <link href="/public/system/css/style.css" rel="stylesheet">
    <link href="/public/system/css/login.css" rel="stylesheet">
    <!--[if lt IE 9]>
    <meta http-equiv="refresh" content="0;ie.html"/>
    <![endif]-->
    <script>
        if (window.top !== window.self) {
            window.top.location = window.location;
        }
    </script>
    <style>
        .signin2{background:url('/public/system/img/bg.jpg') no-repeat top center;}
        .signin2 .signinpanel{background:#fff;width:500px;height:300px;border-radius:20px;box-shadow:2px 2px 2px 2px rgba(0,0,0,0.2)}
        .signin2 .signinpanel form{border:none;background:none;padding:0 30px 30px}
        .signin2 .signinpanel .title{text-align:center;padding:30px;}
    </style>
</head>
<body class="signin2">
<div class="signinpanel">
    <div class="row">
        <a href="" target="_blank"></a>
        <div class="title">
            <img src="/public/system/img/logo.png" alt="">
        </div>
        <div class="col-sm-12">
            <form method="post" id="loginForm">
                <input type="text" id="account" name="account" class="form-control uname" placeholder="请输入帐户"/>
                <input type="password" id="password" name="password" class="form-control pword m-b" placeholder="请输入密码"/>
                <button type="button" class="btn btn-success btn-block" id="btnLogin">登录</button>
            </form>
        </div>
    </div>
    <div class="signup-footer">
        <div class="text-center">
            &copy; 2016 All Rights Reserved. 多用户商城系统
        </div>
    </div>
</div>
<!-- 全局js -->
<script src="/public/plugins/jquery.min.js?v=2.1.4"></script>
<script src="/public/plugins/bootstrap/js/bootstrap.min.js?v=3.3.6"></script>
<script src="/public/plugins/layer/layer.js"></script>
<!--自定义js-->
<!--公共js-->
<script src="/public/system/js/common.js"></script>
<script type="text/javascript">
    $(document).ready(function () {
        $(function () {
            $('#btnLogin').bind('click', function () {
                doLogin();
            });
            document.onkeydown = function (e) {
                var ev = document.all ? window.event : e;
                if (ev.keyCode == 13) {
                    doLogin();
                }
            }
        });
    });
    //用户登录
    function doLogin(){
        var account = $('#account').val();
        var password = $('#password').val();
        if (account == '') {
            layer.alert('帐户不能为空！', {icon: 2});
            return false;
        }
        if (password == '') {
            layer.alert('密码不能为空！', {icon: 2});
            return false;
        }
        var url = "{:url('doLogin')}";
        $.ajax({
            type: 'post',
            url: url,
            data: $('#loginForm').serialize(),
            cache: false,
            async: false,
            beforeSend: function (data) {
                layer.load();
            },
            success: function (data) {
                layer.closeAll();
                if (data.code == 1) {
                    layer.msg(data.msg, {icon: 1, time: 1000, shade: 0.3}, function (index) {
                        layer.close(index);
                        location.href = data.url;
                    });
                } else {
                    layer.alert(data.msg, {icon: 2});
                }
            },
            error: function () {
                layer.closeAll();
                layer.alert('与服务器断开连接！', {icon: 2});
                return false;
            }
        });
    }
</script>
</body>
</html>